package com.shop.dingdongshoppingapi.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.additional.query.impl.QueryChainWrapper;
import com.shop.dingdongshoppingapi.dao.LogisticsDao;
import com.shop.dingdongshoppingapi.entity.Logistics;
import com.shop.dingdongshoppingapi.service.intf.LogisticsService;
import com.shop.dingdongshoppingapi.util.StringUtil;
import com.shop.dingdongshoppingapi.vo.R;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class LogisticeServiceImpl implements LogisticsService {
    @Resource
    private LogisticsDao dao;

    @Override
    public R queryTimeByName(String name) {
        if (StringUtil.isNotEmpty(name)){
            Logistics logistics = dao.selectOne(new QueryWrapper<Logistics>().eq("name", name));

            return R.ok(logistics);
        }
        return R.fail();
    }

    @Override
    public R setPurchaseEndTime(String name) {
        //参数判断
        if (StringUtil.isNotEmpty(name)){
            //根据订单名修改
            if (dao.updatePurchaseend(name)>0){
                //修改成功
                return R.ok();
            }
        }
        return R.fail();
    }
}
